import java.util.Scanner;
public class Lab07_Task02 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int i = s.nextInt();
if (i<1) {
System.out.println("Your class size cannot me less then zero!!!");
System.exit(0);
}
String[] sname = new String[i];
double[][] marks = new double[i][7];
String[] q = new String[i];
double[] avg = new double[i];
double[] sum = new double[i];
int j = 0;
while(i>j) {
sname[j] = s.next();
int x = 0;
while(5>x) {
marks[j][x] = s.nextDouble();
if (marks[j][x]>100) {
System.out.println("Marks above 100 not valid!!!");
System.exit(0);
}
if (marks[j][x]<0) {
System.out.println("Negative marks not allowed!!!");
System.exit(0);
}
if (x == 0) {
marks[j][x] = marks[j][x]/100*20;
}
if (x == 1) {
marks[j][x] = marks[j][x]/100*20;
}
if (x == 2) {
marks[j][x] = marks[j][x]/100*20;
}
if (x == 3) {
marks[j][x] = marks[j][x]/100*10;
}
if (x == 4) {
marks[j][x] = marks[j][x]/100*30;
}
sum[j] = sum[j]+marks[j][x];
x++;
}
if (Math.round(sum[j])==50) {
q[j] = "YES";
} else {
if (sum[j]>50) {
q[j] = "YES";
} else {
q[j] = "NO";
}
}
j++;
}
System.out.println(String.format("%-12s %-18s %-18s", "Student", "Semester mark", "Qualifies for Exam?"));
System.out.println(String.format("%-12s %-18s %-18s", "-------", "--------------", "----------------------"));
j = 0;
while (i>j) {
System.out.println(String.format("%-20s %-12s %-13s", sname[j], Math.round(sum[j]), q[j]));
j++;
}
}
}